package Operation;

import BOOK.Book;
import BOOK.BookList;

/**
 * Creat with IntelliJ IDEA
 * Description:添加图书
 * User:WZW
 * Date:2021-11-27
 * Time:18:40
 */
public class Add implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("增加图书：");
        System.out.print("请输入书名：>");
        String name = scanner.nextLine();
        System.out.print("请输入作者：>");
        String author = scanner.nextLine();
        System.out.print("请输入出版社：>");
        String publisher = scanner.nextLine();
        System.out.print("请输入价格：>");
        float price = scanner.nextFloat();

        int index = bookList.getUsedSize();
        Book book = new Book(name,author,publisher,price);
        bookList.setBooks(index,book);
        bookList.setUsedSize(bookList.getUsedSize()+1);
        System.out.println("增加图书成功！");
    }
}
